
local alien = require "alien"
local config = require "config"
local print, pcall
    = print, pcall
local gmatch = string.gmatch


module (...)


local abi = "stdcall"
local gl = alien.load(config.gl_path)
_M.lib = gl

local function Func(name, types)
  local func = gl["gl" .. name]
  func:types(types)
  _M[name] = func
end

local GLenum = "uint"
local GLboolean = "char"
local GLbitfield = "uint"
local GLbyte = "byte"
local GLshort = "short"
local GLint = "int"
local GLsizei = "int"
local GLubyte = "char"
local GLushort = "ushort"
local GLuint = "uint"
local GLfloat = "float"
local GLclampf = "float"
local GLdouble = "double"
local GLclampd = "double"
local GLvoid = "void"
local void = "void"
local ptr = "pointer"

VERSION_1_1 = 1

-- AccumOp
ACCUM                          = 0x0100
LOAD                           = 0x0101
RETURN                         = 0x0102
MULT                           = 0x0103
ADD                            = 0x0104

-- AlphaFunction
NEVER                          = 0x0200
LESS                           = 0x0201
EQUAL                          = 0x0202
LEQUAL                         = 0x0203
GREATER                        = 0x0204
NOTEQUAL                       = 0x0205
GEQUAL                         = 0x0206
ALWAYS                         = 0x0207

-- AttribMask
CURRENT_BIT                    = 0x00000001
POINT_BIT                      = 0x00000002
LINE_BIT                       = 0x00000004
POLYGON_BIT                    = 0x00000008
POLYGON_STIPPLE_BIT            = 0x00000010
PIXEL_MODE_BIT                 = 0x00000020
LIGHTING_BIT                   = 0x00000040
FOG_BIT                        = 0x00000080
DEPTH_BUFFER_BIT               = 0x00000100
ACCUM_BUFFER_BIT               = 0x00000200
STENCIL_BUFFER_BIT             = 0x00000400
VIEWPORT_BIT                   = 0x00000800
TRANSFORM_BIT                  = 0x00001000
ENABLE_BIT                     = 0x00002000
COLOR_BUFFER_BIT               = 0x00004000
HINT_BIT                       = 0x00008000
EVAL_BIT                       = 0x00010000
LIST_BIT                       = 0x00020000
TEXTURE_BIT                    = 0x00040000
SCISSOR_BIT                    = 0x00080000
ALL_ATTRIB_BITS                = 0x000fffff

-- BeginMode
POINTS                         = 0x0000
LINES                          = 0x0001
LINE_LOOP                      = 0x0002
LINE_STRIP                     = 0x0003
TRIANGLES                      = 0x0004
TRIANGLE_STRIP                 = 0x0005
TRIANGLE_FAN                   = 0x0006
QUADS                          = 0x0007
QUAD_STRIP                     = 0x0008
POLYGON                        = 0x0009

-- BlendingFactorDest
ZERO                           = 0
ONE                            = 1
SRC_COLOR                      = 0x0300
ONE_MINUS_SRC_COLOR            = 0x0301
SRC_ALPHA                      = 0x0302
ONE_MINUS_SRC_ALPHA            = 0x0303
DST_ALPHA                      = 0x0304
ONE_MINUS_DST_ALPHA            = 0x0305

-- BlendingFactorSrc
--      GL_ZERO
--      GL_ONE
DST_COLOR                      = 0x0306
ONE_MINUS_DST_COLOR            = 0x0307
SRC_ALPHA_SATURATE             = 0x0308
--      GL_SRC_ALPHA
--      GL_ONE_MINUS_SRC_ALPHA
--      GL_DST_ALPHA
--      GL_ONE_MINUS_DST_ALPHA

-- Boolean
TRUE                           = 1
FALSE                          = 0

-- ClearBufferMask
--      GL_COLOR_BUFFER_BIT
--      GL_ACCUM_BUFFER_BIT
--      GL_STENCIL_BUFFER_BIT
--      GL_DEPTH_BUFFER_BIT

-- ClientArrayType
--      GL_VERTEX_ARRAY
--      GL_NORMAL_ARRAY
--      GL_COLOR_ARRAY
--      GL_INDEX_ARRAY
--      GL_TEXTURE_COORD_ARRAY
--      GL_EDGE_FLAG_ARRAY

-- ClipPlaneName
CLIP_PLANE0                    = 0x3000
CLIP_PLANE1                    = 0x3001
CLIP_PLANE2                    = 0x3002
CLIP_PLANE3                    = 0x3003
CLIP_PLANE4                    = 0x3004
CLIP_PLANE5                    = 0x3005

-- ColorMaterialFace
--      GL_FRONT
--      GL_BACK
--      GL_FRONT_AND_BACK

-- ColorMaterialParameter
--      GL_AMBIENT
--      GL_DIFFUSE
--      GL_SPECULAR
--      GL_EMISSION
--      GL_AMBIENT_AND_DIFFUSE

-- ColorPointerType
--      GL_BYTE
--      GL_UNSIGNED_BYTE
--      GL_SHORT
--      GL_UNSIGNED_SHORT
--      GL_INT
--      GL_UNSIGNED_INT
--      GL_FLOAT
--      GL_DOUBLE

-- CullFaceMode
--      GL_FRONT
--      GL_BACK
--      GL_FRONT_AND_BACK

-- DataType
BYTE                           = 0x1400
UNSIGNED_BYTE                  = 0x1401
SHORT                          = 0x1402
UNSIGNED_SHORT                 = 0x1403
INT                            = 0x1404
UNSIGNED_INT                   = 0x1405
FLOAT                          = 0x1406
_2_BYTES                        = 0x1407
_3_BYTES                        = 0x1408
_4_BYTES                        = 0x1409
DOUBLE                         = 0x140A

-- DepthFunction
--      GL_NEVER
--      GL_LESS
--      GL_EQUAL
--      GL_LEQUAL
--      GL_GREATER
--      GL_NOTEQUAL
--      GL_GEQUAL
--      GL_ALWAYS

-- DrawBufferMode
NONE                           = 0
FRONT_LEFT                     = 0x0400
FRONT_RIGHT                    = 0x0401
BACK_LEFT                      = 0x0402
BACK_RIGHT                     = 0x0403
FRONT                          = 0x0404
BACK                           = 0x0405
LEFT                           = 0x0406
RIGHT                          = 0x0407
FRONT_AND_BACK                 = 0x0408
AUX0                           = 0x0409
AUX1                           = 0x040A
AUX2                           = 0x040B
AUX3                           = 0x040C

-- Enable
--      GL_FOG
--      GL_LIGHTING
--      GL_TEXTURE_1D
--      GL_TEXTURE_2D
--      GL_LINE_STIPPLE
--      GL_POLYGON_STIPPLE
--      GL_CULL_FACE
--      GL_ALPHA_TEST
--      GL_BLEND
--      GL_INDEX_LOGIC_OP
--      GL_COLOR_LOGIC_OP
--      GL_DITHER
--      GL_STENCIL_TEST
--      GL_DEPTH_TEST
--      GL_CLIP_PLANE0
--      GL_CLIP_PLANE1
--      GL_CLIP_PLANE2
--      GL_CLIP_PLANE3
--      GL_CLIP_PLANE4
--      GL_CLIP_PLANE5
--      GL_LIGHT0
--      GL_LIGHT1
--      GL_LIGHT2
--      GL_LIGHT3
--      GL_LIGHT4
--      GL_LIGHT5
--      GL_LIGHT6
--      GL_LIGHT7
--      GL_TEXTURE_GEN_S
--      GL_TEXTURE_GEN_T
--      GL_TEXTURE_GEN_R
--      GL_TEXTURE_GEN_Q
--      GL_MAP1_VERTEX_3
--      GL_MAP1_VERTEX_4
--      GL_MAP1_COLOR_4
--      GL_MAP1_INDEX
--      GL_MAP1_NORMAL
--      GL_MAP1_TEXTURE_COORD_1
--      GL_MAP1_TEXTURE_COORD_2
--      GL_MAP1_TEXTURE_COORD_3
--      GL_MAP1_TEXTURE_COORD_4
--      GL_MAP2_VERTEX_3
--      GL_MAP2_VERTEX_4
--      GL_MAP2_COLOR_4
--      GL_MAP2_INDEX
--      GL_MAP2_NORMAL
--      GL_MAP2_TEXTURE_COORD_1
--      GL_MAP2_TEXTURE_COORD_2
--      GL_MAP2_TEXTURE_COORD_3
--      GL_MAP2_TEXTURE_COORD_4
--      GL_POINT_SMOOTH
--      GL_LINE_SMOOTH
--      GL_POLYGON_SMOOTH
--      GL_SCISSOR_TEST
--      GL_COLOR_MATERIAL
--      GL_NORMALIZE
--      GL_AUTO_NORMAL
--      GL_VERTEX_ARRAY
--      GL_NORMAL_ARRAY
--      GL_COLOR_ARRAY
--      GL_INDEX_ARRAY
--      GL_TEXTURE_COORD_ARRAY
--      GL_EDGE_FLAG_ARRAY
--      GL_POLYGON_OFFSET_POINT
--      GL_POLYGON_OFFSET_LINE
--      GL_POLYGON_OFFSET_FILL

-- ErrorCode
NO_ERROR                       = 0
INVALID_ENUM                   = 0x0500
INVALID_VALUE                  = 0x0501
INVALID_OPERATION              = 0x0502
STACK_OVERFLOW                 = 0x0503
STACK_UNDERFLOW                = 0x0504
OUT_OF_MEMORY                  = 0x0505

-- FeedBackMode
_2D                             = 0x0600
_3D                             = 0x0601
_3D_COLOR                       = 0x0602
_3D_COLOR_TEXTURE               = 0x0603
_4D_COLOR_TEXTURE               = 0x0604

-- FeedBackToken
PASS_THROUGH_TOKEN             = 0x0700
POINT_TOKEN                    = 0x0701
LINE_TOKEN                     = 0x0702
POLYGON_TOKEN                  = 0x0703
BITMAP_TOKEN                   = 0x0704
DRAW_PIXEL_TOKEN               = 0x0705
COPY_PIXEL_TOKEN               = 0x0706
LINE_RESET_TOKEN               = 0x0707

-- FogMode
--      GL_LINEAR
EXP                            = 0x0800
EXP2                           = 0x0801


-- FogParameter
--      GL_FOG_COLOR
--      GL_FOG_DENSITY
--      GL_FOG_END
--      GL_FOG_INDEX
--      GL_FOG_MODE
--      GL_FOG_START

-- FrontFaceDirection
CW                             = 0x0900
CCW                            = 0x0901

-- GetMapTarget
COEFF                          = 0x0A00
ORDER                          = 0x0A01
DOMAIN                         = 0x0A02

-- GetPixelMap
--      GL_PIXEL_MAP_I_TO_I
--      GL_PIXEL_MAP_S_TO_S
--      GL_PIXEL_MAP_I_TO_R
--      GL_PIXEL_MAP_I_TO_G
--      GL_PIXEL_MAP_I_TO_B
--      GL_PIXEL_MAP_I_TO_A
--      GL_PIXEL_MAP_R_TO_R
--      GL_PIXEL_MAP_G_TO_G
--      GL_PIXEL_MAP_B_TO_B
--      GL_PIXEL_MAP_A_TO_A

-- GetPointerTarget
--      GL_VERTEX_ARRAY_POINTER
--      GL_NORMAL_ARRAY_POINTER
--      GL_COLOR_ARRAY_POINTER
--      GL_INDEX_ARRAY_POINTER
--      GL_TEXTURE_COORD_ARRAY_POINTER
--      GL_EDGE_FLAG_ARRAY_POINTER

-- GetTarget
CURRENT_COLOR                  = 0x0B00
CURRENT_INDEX                  = 0x0B01
CURRENT_NORMAL                 = 0x0B02
CURRENT_TEXTURE_COORDS         = 0x0B03
CURRENT_RASTER_COLOR           = 0x0B04
CURRENT_RASTER_INDEX           = 0x0B05
CURRENT_RASTER_TEXTURE_COORDS  = 0x0B06
CURRENT_RASTER_POSITION        = 0x0B07
CURRENT_RASTER_POSITION_VALID  = 0x0B08
CURRENT_RASTER_DISTANCE        = 0x0B09
POINT_SMOOTH                   = 0x0B10
POINT_SIZE                     = 0x0B11
POINT_SIZE_RANGE               = 0x0B12
POINT_SIZE_GRANULARITY         = 0x0B13
LINE_SMOOTH                    = 0x0B20
LINE_WIDTH                     = 0x0B21
LINE_WIDTH_RANGE               = 0x0B22
LINE_WIDTH_GRANULARITY         = 0x0B23
LINE_STIPPLE                   = 0x0B24
LINE_STIPPLE_PATTERN           = 0x0B25
LINE_STIPPLE_REPEAT            = 0x0B26
LIST_MODE                      = 0x0B30
MAX_LIST_NESTING               = 0x0B31
LIST_BASE                      = 0x0B32
LIST_INDEX                     = 0x0B33
POLYGON_MODE                   = 0x0B40
POLYGON_SMOOTH                 = 0x0B41
POLYGON_STIPPLE                = 0x0B42
EDGE_FLAG                      = 0x0B43
CULL_FACE                      = 0x0B44
CULL_FACE_MODE                 = 0x0B45
FRONT_FACE                     = 0x0B46
LIGHTING                       = 0x0B50
LIGHT_MODEL_LOCAL_VIEWER       = 0x0B51
LIGHT_MODEL_TWO_SIDE           = 0x0B52
LIGHT_MODEL_AMBIENT            = 0x0B53
SHADE_MODEL                    = 0x0B54
COLOR_MATERIAL_FACE            = 0x0B55
COLOR_MATERIAL_PARAMETER       = 0x0B56
COLOR_MATERIAL                 = 0x0B57
FOG                            = 0x0B60
FOG_INDEX                      = 0x0B61
FOG_DENSITY                    = 0x0B62
FOG_START                      = 0x0B63
FOG_END                        = 0x0B64
FOG_MODE                       = 0x0B65
FOG_COLOR                      = 0x0B66
DEPTH_RANGE                    = 0x0B70
DEPTH_TEST                     = 0x0B71
DEPTH_WRITEMASK                = 0x0B72
DEPTH_CLEAR_VALUE              = 0x0B73
DEPTH_FUNC                     = 0x0B74
ACCUM_CLEAR_VALUE              = 0x0B80
STENCIL_TEST                   = 0x0B90
STENCIL_CLEAR_VALUE            = 0x0B91
STENCIL_FUNC                   = 0x0B92
STENCIL_VALUE_MASK             = 0x0B93
STENCIL_FAIL                   = 0x0B94
STENCIL_PASS_DEPTH_FAIL        = 0x0B95
STENCIL_PASS_DEPTH_PASS        = 0x0B96
STENCIL_REF                    = 0x0B97
STENCIL_WRITEMASK              = 0x0B98
MATRIX_MODE                    = 0x0BA0
NORMALIZE                      = 0x0BA1
VIEWPORT                       = 0x0BA2
MODELVIEW_STACK_DEPTH          = 0x0BA3
PROJECTION_STACK_DEPTH         = 0x0BA4
TEXTURE_STACK_DEPTH            = 0x0BA5
MODELVIEW_MATRIX               = 0x0BA6
PROJECTION_MATRIX              = 0x0BA7
TEXTURE_MATRIX                 = 0x0BA8
ATTRIB_STACK_DEPTH             = 0x0BB0
CLIENT_ATTRIB_STACK_DEPTH      = 0x0BB1
ALPHA_TEST                     = 0x0BC0
ALPHA_TEST_FUNC                = 0x0BC1
ALPHA_TEST_REF                 = 0x0BC2
DITHER                         = 0x0BD0
BLEND_DST                      = 0x0BE0
BLEND_SRC                      = 0x0BE1
BLEND                          = 0x0BE2
LOGIC_OP_MODE                  = 0x0BF0
INDEX_LOGIC_OP                 = 0x0BF1
COLOR_LOGIC_OP                 = 0x0BF2
AUX_BUFFERS                    = 0x0C00
DRAW_BUFFER                    = 0x0C01
READ_BUFFER                    = 0x0C02
SCISSOR_BOX                    = 0x0C10
SCISSOR_TEST                   = 0x0C11
INDEX_CLEAR_VALUE              = 0x0C20
INDEX_WRITEMASK                = 0x0C21
COLOR_CLEAR_VALUE              = 0x0C22
COLOR_WRITEMASK                = 0x0C23
INDEX_MODE                     = 0x0C30
RGBA_MODE                      = 0x0C31
DOUBLEBUFFER                   = 0x0C32
STEREO                         = 0x0C33
RENDER_MODE                    = 0x0C40
PERSPECTIVE_CORRECTION_HINT    = 0x0C50
POINT_SMOOTH_HINT              = 0x0C51
LINE_SMOOTH_HINT               = 0x0C52
POLYGON_SMOOTH_HINT            = 0x0C53
FOG_HINT                       = 0x0C54
TEXTURE_GEN_S                  = 0x0C60
TEXTURE_GEN_T                  = 0x0C61
TEXTURE_GEN_R                  = 0x0C62
TEXTURE_GEN_Q                  = 0x0C63
PIXEL_MAP_I_TO_I               = 0x0C70
PIXEL_MAP_S_TO_S               = 0x0C71
PIXEL_MAP_I_TO_R               = 0x0C72
PIXEL_MAP_I_TO_G               = 0x0C73
PIXEL_MAP_I_TO_B               = 0x0C74
PIXEL_MAP_I_TO_A               = 0x0C75
PIXEL_MAP_R_TO_R               = 0x0C76
PIXEL_MAP_G_TO_G               = 0x0C77
PIXEL_MAP_B_TO_B               = 0x0C78
PIXEL_MAP_A_TO_A               = 0x0C79
PIXEL_MAP_I_TO_I_SIZE          = 0x0CB0
PIXEL_MAP_S_TO_S_SIZE          = 0x0CB1
PIXEL_MAP_I_TO_R_SIZE          = 0x0CB2
PIXEL_MAP_I_TO_G_SIZE          = 0x0CB3
PIXEL_MAP_I_TO_B_SIZE          = 0x0CB4
PIXEL_MAP_I_TO_A_SIZE          = 0x0CB5
PIXEL_MAP_R_TO_R_SIZE          = 0x0CB6
PIXEL_MAP_G_TO_G_SIZE          = 0x0CB7
PIXEL_MAP_B_TO_B_SIZE          = 0x0CB8
PIXEL_MAP_A_TO_A_SIZE          = 0x0CB9
UNPACK_SWAP_BYTES              = 0x0CF0
UNPACK_LSB_FIRST               = 0x0CF1
UNPACK_ROW_LENGTH              = 0x0CF2
UNPACK_SKIP_ROWS               = 0x0CF3
UNPACK_SKIP_PIXELS             = 0x0CF4
UNPACK_ALIGNMENT               = 0x0CF5
PACK_SWAP_BYTES                = 0x0D00
PACK_LSB_FIRST                 = 0x0D01
PACK_ROW_LENGTH                = 0x0D02
PACK_SKIP_ROWS                 = 0x0D03
PACK_SKIP_PIXELS               = 0x0D04
PACK_ALIGNMENT                 = 0x0D05
MAP_COLOR                      = 0x0D10
MAP_STENCIL                    = 0x0D11
INDEX_SHIFT                    = 0x0D12
INDEX_OFFSET                   = 0x0D13
RED_SCALE                      = 0x0D14
RED_BIAS                       = 0x0D15
ZOOM_X                         = 0x0D16
ZOOM_Y                         = 0x0D17
GREEN_SCALE                    = 0x0D18
GREEN_BIAS                     = 0x0D19
BLUE_SCALE                     = 0x0D1A
BLUE_BIAS                      = 0x0D1B
ALPHA_SCALE                    = 0x0D1C
ALPHA_BIAS                     = 0x0D1D
DEPTH_SCALE                    = 0x0D1E
DEPTH_BIAS                     = 0x0D1F
MAX_EVAL_ORDER                 = 0x0D30
MAX_LIGHTS                     = 0x0D31
MAX_CLIP_PLANES                = 0x0D32
MAX_TEXTURE_SIZE               = 0x0D33
MAX_PIXEL_MAP_TABLE            = 0x0D34
MAX_ATTRIB_STACK_DEPTH         = 0x0D35
MAX_MODELVIEW_STACK_DEPTH      = 0x0D36
MAX_NAME_STACK_DEPTH           = 0x0D37
MAX_PROJECTION_STACK_DEPTH     = 0x0D38
MAX_TEXTURE_STACK_DEPTH        = 0x0D39
MAX_VIEWPORT_DIMS              = 0x0D3A
MAX_CLIENT_ATTRIB_STACK_DEPTH  = 0x0D3B
SUBPIXEL_BITS                  = 0x0D50
INDEX_BITS                     = 0x0D51
RED_BITS                       = 0x0D52
GREEN_BITS                     = 0x0D53
BLUE_BITS                      = 0x0D54
ALPHA_BITS                     = 0x0D55
DEPTH_BITS                     = 0x0D56
STENCIL_BITS                   = 0x0D57
ACCUM_RED_BITS                 = 0x0D58
ACCUM_GREEN_BITS               = 0x0D59
ACCUM_BLUE_BITS                = 0x0D5A
ACCUM_ALPHA_BITS               = 0x0D5B
NAME_STACK_DEPTH               = 0x0D70
AUTO_NORMAL                    = 0x0D80
MAP1_COLOR_4                   = 0x0D90
MAP1_INDEX                     = 0x0D91
MAP1_NORMAL                    = 0x0D92
MAP1_TEXTURE_COORD_1           = 0x0D93
MAP1_TEXTURE_COORD_2           = 0x0D94
MAP1_TEXTURE_COORD_3           = 0x0D95
MAP1_TEXTURE_COORD_4           = 0x0D96
MAP1_VERTEX_3                  = 0x0D97
MAP1_VERTEX_4                  = 0x0D98
MAP2_COLOR_4                   = 0x0DB0
MAP2_INDEX                     = 0x0DB1
MAP2_NORMAL                    = 0x0DB2
MAP2_TEXTURE_COORD_1           = 0x0DB3
MAP2_TEXTURE_COORD_2           = 0x0DB4
MAP2_TEXTURE_COORD_3           = 0x0DB5
MAP2_TEXTURE_COORD_4           = 0x0DB6
MAP2_VERTEX_3                  = 0x0DB7
MAP2_VERTEX_4                  = 0x0DB8
MAP1_GRID_DOMAIN               = 0x0DD0
MAP1_GRID_SEGMENTS             = 0x0DD1
MAP2_GRID_DOMAIN               = 0x0DD2
MAP2_GRID_SEGMENTS             = 0x0DD3
TEXTURE_1D                     = 0x0DE0
TEXTURE_2D                     = 0x0DE1
FEEDBACK_BUFFER_POINTER        = 0x0DF0
FEEDBACK_BUFFER_SIZE           = 0x0DF1
FEEDBACK_BUFFER_TYPE           = 0x0DF2
SELECTION_BUFFER_POINTER       = 0x0DF3
SELECTION_BUFFER_SIZE          = 0x0DF4
--      GL_TEXTURE_BINDING_1D
--      GL_TEXTURE_BINDING_2D
--      GL_VERTEX_ARRAY
--      GL_NORMAL_ARRAY
--      GL_COLOR_ARRAY
--      GL_INDEX_ARRAY
--      GL_TEXTURE_COORD_ARRAY
--      GL_EDGE_FLAG_ARRAY
--      GL_VERTEX_ARRAY_SIZE
--      GL_VERTEX_ARRAY_TYPE
--      GL_VERTEX_ARRAY_STRIDE
--      GL_NORMAL_ARRAY_TYPE
--      GL_NORMAL_ARRAY_STRIDE
--      GL_COLOR_ARRAY_SIZE
--      GL_COLOR_ARRAY_TYPE
--      GL_COLOR_ARRAY_STRIDE
--      GL_INDEX_ARRAY_TYPE
--      GL_INDEX_ARRAY_STRIDE
--      GL_TEXTURE_COORD_ARRAY_SIZE
--      GL_TEXTURE_COORD_ARRAY_TYPE
--      GL_TEXTURE_COORD_ARRAY_STRIDE
--      GL_EDGE_FLAG_ARRAY_STRIDE
--      GL_POLYGON_OFFSET_FACTOR
--      GL_POLYGON_OFFSET_UNITS

-- GetTextureParameter
--      GL_TEXTURE_MAG_FILTER
--      GL_TEXTURE_MIN_FILTER
--      GL_TEXTURE_WRAP_S
--      GL_TEXTURE_WRAP_T
TEXTURE_WIDTH                  = 0x1000
TEXTURE_HEIGHT                 = 0x1001
TEXTURE_INTERNAL_FORMAT        = 0x1003
TEXTURE_BORDER_COLOR           = 0x1004
TEXTURE_BORDER                 = 0x1005
--      GL_TEXTURE_RED_SIZE
--      GL_TEXTURE_GREEN_SIZE
--      GL_TEXTURE_BLUE_SIZE
--      GL_TEXTURE_ALPHA_SIZE
--      GL_TEXTURE_LUMINANCE_SIZE
--      GL_TEXTURE_INTENSITY_SIZE
--      GL_TEXTURE_PRIORITY
--      GL_TEXTURE_RESIDENT

-- HintMode
DONT_CARE                      = 0x1100
FASTEST                        = 0x1101
NICEST                         = 0x1102

-- HintTarget
--      GL_PERSPECTIVE_CORRECTION_HINT
--      GL_POINT_SMOOTH_HINT
--      GL_LINE_SMOOTH_HINT
--      GL_POLYGON_SMOOTH_HINT
--      GL_FOG_HINT
--      GL_PHONG_HINT

-- IndexPointerType
--      GL_SHORT
--      GL_INT
--      GL_FLOAT
--      GL_DOUBLE

-- LightModelParameter
--      GL_LIGHT_MODEL_AMBIENT
--      GL_LIGHT_MODEL_LOCAL_VIEWER
--      GL_LIGHT_MODEL_TWO_SIDE

-- LightName
LIGHT0                         = 0x4000
LIGHT1                         = 0x4001
LIGHT2                         = 0x4002
LIGHT3                         = 0x4003
LIGHT4                         = 0x4004
LIGHT5                         = 0x4005
LIGHT6                         = 0x4006
LIGHT7                         = 0x4007

-- LightParameter
AMBIENT                        = 0x1200
DIFFUSE                        = 0x1201
SPECULAR                       = 0x1202
POSITION                       = 0x1203
SPOT_DIRECTION                 = 0x1204
SPOT_EXPONENT                  = 0x1205
SPOT_CUTOFF                    = 0x1206
CONSTANT_ATTENUATION           = 0x1207
LINEAR_ATTENUATION             = 0x1208
QUADRATIC_ATTENUATION          = 0x1209

-- InterleavedArrays
--      GL_V2F
--      GL_V3F
--      GL_C4UB_V2F
--      GL_C4UB_V3F
--      GL_C3F_V3F
--      GL_N3F_V3F
--      GL_C4F_N3F_V3F
--      GL_T2F_V3F
--      GL_T4F_V4F
--      GL_T2F_C4UB_V3F
--      GL_T2F_C3F_V3F
--      GL_T2F_N3F_V3F
--      GL_T2F_C4F_N3F_V3F
--      GL_T4F_C4F_N3F_V4F

-- ListMode
COMPILE                        = 0x1300
COMPILE_AND_EXECUTE            = 0x1301

-- ListNameType
--      GL_BYTE
--      GL_UNSIGNED_BYTE
--      GL_SHORT
--      GL_UNSIGNED_SHORT
--      GL_INT
--      GL_UNSIGNED_INT
--      GL_FLOAT
--      GL_2_BYTES
--      GL_3_BYTES
--      GL_4_BYTES

-- LogicOp
CLEAR                          = 0x1500
AND                            = 0x1501
AND_REVERSE                    = 0x1502
COPY                           = 0x1503
AND_INVERTED                   = 0x1504
NOOP                           = 0x1505
XOR                            = 0x1506
OR                             = 0x1507
NOR                            = 0x1508
EQUIV                          = 0x1509
INVERT                         = 0x150A
OR_REVERSE                     = 0x150B
COPY_INVERTED                  = 0x150C
OR_INVERTED                    = 0x150D
NAND                           = 0x150E
SET                            = 0x150F

-- MapTarget
--      GL_MAP1_COLOR_4
--      GL_MAP1_INDEX
--      GL_MAP1_NORMAL
--      GL_MAP1_TEXTURE_COORD_1
--      GL_MAP1_TEXTURE_COORD_2
--      GL_MAP1_TEXTURE_COORD_3
--      GL_MAP1_TEXTURE_COORD_4
--      GL_MAP1_VERTEX_3
--      GL_MAP1_VERTEX_4
--      GL_MAP2_COLOR_4
--      GL_MAP2_INDEX
--      GL_MAP2_NORMAL
--      GL_MAP2_TEXTURE_COORD_1
--      GL_MAP2_TEXTURE_COORD_2
--      GL_MAP2_TEXTURE_COORD_3
--      GL_MAP2_TEXTURE_COORD_4
--      GL_MAP2_VERTEX_3
--      GL_MAP2_VERTEX_4

-- MaterialFace
--      GL_FRONT
--      GL_BACK
--      GL_FRONT_AND_BACK

-- MaterialParameter
EMISSION                       = 0x1600
SHININESS                      = 0x1601
AMBIENT_AND_DIFFUSE            = 0x1602
COLOR_INDEXES                  = 0x1603
--      GL_AMBIENT
--      GL_DIFFUSE
--      GL_SPECULAR

-- MatrixMode
MODELVIEW                      = 0x1700
PROJECTION                     = 0x1701
TEXTURE                        = 0x1702

-- MeshMode1
--      GL_POINT
--      GL_LINE

-- MeshMode2
--      GL_POINT
--      GL_LINE
--      GL_FILL

-- NormalPointerType
--      GL_BYTE
--      GL_SHORT
--      GL_INT
--      GL_FLOAT
--      GL_DOUBLE

-- PixelCopyType
COLOR                          = 0x1800
DEPTH                          = 0x1801
STENCIL                        = 0x1802

-- PixelFormat
COLOR_INDEX                    = 0x1900
STENCIL_INDEX                  = 0x1901
DEPTH_COMPONENT                = 0x1902
RED                            = 0x1903
GREEN                          = 0x1904
BLUE                           = 0x1905
ALPHA                          = 0x1906
RGB                            = 0x1907
RGBA                           = 0x1908
LUMINANCE                      = 0x1909
LUMINANCE_ALPHA                = 0x190A

-- PixelMap
--      GL_PIXEL_MAP_I_TO_I
--      GL_PIXEL_MAP_S_TO_S
--      GL_PIXEL_MAP_I_TO_R
--      GL_PIXEL_MAP_I_TO_G
--      GL_PIXEL_MAP_I_TO_B
--      GL_PIXEL_MAP_I_TO_A
--      GL_PIXEL_MAP_R_TO_R
--      GL_PIXEL_MAP_G_TO_G
--      GL_PIXEL_MAP_B_TO_B
--      GL_PIXEL_MAP_A_TO_A

-- PixelStore
--      GL_UNPACK_SWAP_BYTES
--      GL_UNPACK_LSB_FIRST
--      GL_UNPACK_ROW_LENGTH
--      GL_UNPACK_SKIP_ROWS
--      GL_UNPACK_SKIP_PIXELS
--      GL_UNPACK_ALIGNMENT
--      GL_PACK_SWAP_BYTES
--      GL_PACK_LSB_FIRST
--      GL_PACK_ROW_LENGTH
--      GL_PACK_SKIP_ROWS
--      GL_PACK_SKIP_PIXELS
--      GL_PACK_ALIGNMENT

-- PixelTransfer
--      GL_MAP_COLOR
--      GL_MAP_STENCIL
--      GL_INDEX_SHIFT
--      GL_INDEX_OFFSET
--      GL_RED_SCALE
--      GL_RED_BIAS
--      GL_GREEN_SCALE
--      GL_GREEN_BIAS
--      GL_BLUE_SCALE
--      GL_BLUE_BIAS
--      GL_ALPHA_SCALE
--      GL_ALPHA_BIAS
--      GL_DEPTH_SCALE
--      GL_DEPTH_BIAS

-- PixelType
BITMAP                         = 0x1A00
--      GL_BYTE
--      GL_UNSIGNED_BYTE
--      GL_SHORT
--      GL_UNSIGNED_SHORT
--      GL_INT
--      GL_UNSIGNED_INT
--      GL_FLOAT

-- PolygonMode
POINT                          = 0x1B00
LINE                           = 0x1B01
FILL                           = 0x1B02

-- ReadBufferMode
--      GL_FRONT_LEFT
--      GL_FRONT_RIGHT
--      GL_BACK_LEFT
--      GL_BACK_RIGHT
--      GL_FRONT
--      GL_BACK
--      GL_LEFT
--      GL_RIGHT
--      GL_AUX0
--      GL_AUX1
--      GL_AUX2
--      GL_AUX3

-- RenderingMode
RENDER                         = 0x1C00
FEEDBACK                       = 0x1C01
SELECT                         = 0x1C02

-- ShadingModel
FLAT                           = 0x1D00
SMOOTH                         = 0x1D01


-- StencilFunction
--      GL_NEVER
--      GL_LESS
--      GL_EQUAL
--      GL_LEQUAL
--      GL_GREATER
--      GL_NOTEQUAL
--      GL_GEQUAL
--      GL_ALWAYS

-- StencilOp
--      GL_ZERO
KEEP                           = 0x1E00
REPLACE                        = 0x1E01
INCR                           = 0x1E02
DECR                           = 0x1E03
--      GL_INVERT

-- StringName
VENDOR                         = 0x1F00
RENDERER                       = 0x1F01
VERSION                        = 0x1F02
EXTENSIONS                     = 0x1F03

-- TextureCoordName
S                              = 0x2000
T                              = 0x2001
R                              = 0x2002
Q                              = 0x2003

-- TexCoordPointerType
--      GL_SHORT
--      GL_INT
--      GL_FLOAT
--      GL_DOUBLE

-- TextureEnvMode
MODULATE                       = 0x2100
DECAL                          = 0x2101
--      GL_BLEND
--      GL_REPLACE

-- TextureEnvParameter
TEXTURE_ENV_MODE               = 0x2200
TEXTURE_ENV_COLOR              = 0x2201

-- TextureEnvTarget
TEXTURE_ENV                    = 0x2300

-- TextureGenMode
EYE_LINEAR                     = 0x2400
OBJECT_LINEAR                  = 0x2401
SPHERE_MAP                     = 0x2402

-- TextureGenParameter
TEXTURE_GEN_MODE               = 0x2500
OBJECT_PLANE                   = 0x2501
EYE_PLANE                      = 0x2502

-- TextureMagFilter
NEAREST                        = 0x2600
LINEAR                         = 0x2601

-- TextureMinFilter
--      GL_NEAREST
--      GL_LINEAR
NEAREST_MIPMAP_NEAREST         = 0x2700
LINEAR_MIPMAP_NEAREST          = 0x2701
NEAREST_MIPMAP_LINEAR          = 0x2702
LINEAR_MIPMAP_LINEAR           = 0x2703

-- TextureParameterName
TEXTURE_MAG_FILTER             = 0x2800
TEXTURE_MIN_FILTER             = 0x2801
TEXTURE_WRAP_S                 = 0x2802
TEXTURE_WRAP_T                 = 0x2803
--      GL_TEXTURE_BORDER_COLOR
--      GL_TEXTURE_PRIORITY

-- TextureTarget
--      GL_TEXTURE_1D
--      GL_TEXTURE_2D
--      GL_PROXY_TEXTURE_1D
--      GL_PROXY_TEXTURE_2D

-- TextureWrapMode
CLAMP                          = 0x2900
REPEAT                         = 0x2901

-- VertexPointerType
--      GL_SHORT
--      GL_INT
--      GL_FLOAT
--      GL_DOUBLE

-- ClientAttribMask
CLIENT_PIXEL_STORE_BIT         = 0x00000001
CLIENT_VERTEX_ARRAY_BIT        = 0x00000002
CLIENT_ALL_ATTRIB_BITS         = 0xffffffff

-- polygon_offset
POLYGON_OFFSET_FACTOR          = 0x8038
POLYGON_OFFSET_UNITS           = 0x2A00
POLYGON_OFFSET_POINT           = 0x2A01
POLYGON_OFFSET_LINE            = 0x2A02
POLYGON_OFFSET_FILL            = 0x8037

-- texture
ALPHA4                         = 0x803B
ALPHA8                         = 0x803C
ALPHA12                        = 0x803D
ALPHA16                        = 0x803E
LUMINANCE4                     = 0x803F
LUMINANCE8                     = 0x8040
LUMINANCE12                    = 0x8041
LUMINANCE16                    = 0x8042
LUMINANCE4_ALPHA4              = 0x8043
LUMINANCE6_ALPHA2              = 0x8044
LUMINANCE8_ALPHA8              = 0x8045
LUMINANCE12_ALPHA4             = 0x8046
LUMINANCE12_ALPHA12            = 0x8047
LUMINANCE16_ALPHA16            = 0x8048
INTENSITY                      = 0x8049
INTENSITY4                     = 0x804A
INTENSITY8                     = 0x804B
INTENSITY12                    = 0x804C
INTENSITY16                    = 0x804D
R3_G3_B2                       = 0x2A10
RGB4                           = 0x804F
RGB5                           = 0x8050
RGB8                           = 0x8051
RGB10                          = 0x8052
RGB12                          = 0x8053
RGB16                          = 0x8054
RGBA2                          = 0x8055
RGBA4                          = 0x8056
RGB5_A1                        = 0x8057
RGBA8                          = 0x8058
RGB10_A2                       = 0x8059
RGBA12                         = 0x805A
RGBA16                         = 0x805B
TEXTURE_RED_SIZE               = 0x805C
TEXTURE_GREEN_SIZE             = 0x805D
TEXTURE_BLUE_SIZE              = 0x805E
TEXTURE_ALPHA_SIZE             = 0x805F
TEXTURE_LUMINANCE_SIZE         = 0x8060
TEXTURE_INTENSITY_SIZE         = 0x8061
PROXY_TEXTURE_1D               = 0x8063
PROXY_TEXTURE_2D               = 0x8064

-- texture_object
TEXTURE_PRIORITY               = 0x8066
TEXTURE_RESIDENT               = 0x8067
TEXTURE_BINDING_1D             = 0x8068
TEXTURE_BINDING_2D             = 0x8069

-- vertex_array
VERTEX_ARRAY                   = 0x8074
NORMAL_ARRAY                   = 0x8075
COLOR_ARRAY                    = 0x8076
INDEX_ARRAY                    = 0x8077
TEXTURE_COORD_ARRAY            = 0x8078
EDGE_FLAG_ARRAY                = 0x8079
VERTEX_ARRAY_SIZE              = 0x807A
VERTEX_ARRAY_TYPE              = 0x807B
VERTEX_ARRAY_STRIDE            = 0x807C
NORMAL_ARRAY_TYPE              = 0x807E
NORMAL_ARRAY_STRIDE            = 0x807F
COLOR_ARRAY_SIZE               = 0x8081
COLOR_ARRAY_TYPE               = 0x8082
COLOR_ARRAY_STRIDE             = 0x8083
INDEX_ARRAY_TYPE               = 0x8085
INDEX_ARRAY_STRIDE             = 0x8086
TEXTURE_COORD_ARRAY_SIZE       = 0x8088
TEXTURE_COORD_ARRAY_TYPE       = 0x8089
TEXTURE_COORD_ARRAY_STRIDE     = 0x808A
EDGE_FLAG_ARRAY_STRIDE         = 0x808C
VERTEX_ARRAY_POINTER           = 0x808E
NORMAL_ARRAY_POINTER           = 0x808F
COLOR_ARRAY_POINTER            = 0x8090
INDEX_ARRAY_POINTER            = 0x8091
TEXTURE_COORD_ARRAY_POINTER    = 0x8092
EDGE_FLAG_ARRAY_POINTER        = 0x8093
V2F                            = 0x2A20
V3F                            = 0x2A21
C4UB_V2F                       = 0x2A22
C4UB_V3F                       = 0x2A23
C3F_V3F                        = 0x2A24
N3F_V3F                        = 0x2A25
C4F_N3F_V3F                    = 0x2A26
T2F_V3F                        = 0x2A27
T4F_V4F                        = 0x2A28
T2F_C4UB_V3F                   = 0x2A29
T2F_C3F_V3F                    = 0x2A2A
T2F_N3F_V3F                    = 0x2A2B
T2F_C4F_N3F_V3F                = 0x2A2C
T4F_C4F_N3F_V4F                = 0x2A2D

-- Extensions
EXT_vertex_array               = 1
EXT_bgra                       = 1
EXT_paletted_texture           = 1
WIN_swap_hint                  = 1
WIN_draw_range_elements        = 1
-- GL_WIN_phong_shading              = 1
-- GL_WIN_specular_fog               = 1

-- EXT_vertex_array
VERTEX_ARRAY_EXT               = 0x8074
NORMAL_ARRAY_EXT               = 0x8075
COLOR_ARRAY_EXT                = 0x8076
INDEX_ARRAY_EXT                = 0x8077
TEXTURE_COORD_ARRAY_EXT        = 0x8078
EDGE_FLAG_ARRAY_EXT            = 0x8079
VERTEX_ARRAY_SIZE_EXT          = 0x807A
VERTEX_ARRAY_TYPE_EXT          = 0x807B
VERTEX_ARRAY_STRIDE_EXT        = 0x807C
VERTEX_ARRAY_COUNT_EXT         = 0x807D
NORMAL_ARRAY_TYPE_EXT          = 0x807E
NORMAL_ARRAY_STRIDE_EXT        = 0x807F
NORMAL_ARRAY_COUNT_EXT         = 0x8080
COLOR_ARRAY_SIZE_EXT           = 0x8081
COLOR_ARRAY_TYPE_EXT           = 0x8082
COLOR_ARRAY_STRIDE_EXT         = 0x8083
COLOR_ARRAY_COUNT_EXT          = 0x8084
INDEX_ARRAY_TYPE_EXT           = 0x8085
INDEX_ARRAY_STRIDE_EXT         = 0x8086
INDEX_ARRAY_COUNT_EXT          = 0x8087
TEXTURE_COORD_ARRAY_SIZE_EXT   = 0x8088
TEXTURE_COORD_ARRAY_TYPE_EXT   = 0x8089
TEXTURE_COORD_ARRAY_STRIDE_EXT = 0x808A
TEXTURE_COORD_ARRAY_COUNT_EXT  = 0x808B
EDGE_FLAG_ARRAY_STRIDE_EXT     = 0x808C
EDGE_FLAG_ARRAY_COUNT_EXT      = 0x808D
VERTEX_ARRAY_POINTER_EXT       = 0x808E
NORMAL_ARRAY_POINTER_EXT       = 0x808F
COLOR_ARRAY_POINTER_EXT        = 0x8090
INDEX_ARRAY_POINTER_EXT        = 0x8091
TEXTURE_COORD_ARRAY_POINTER_EXT = 0x8092
EDGE_FLAG_ARRAY_POINTER_EXT    = 0x8093
DOUBLE_EXT                     = DOUBLE

-- EXT_bgra
BGR_EXT                        = 0x80E0
BGRA_EXT                       = 0x80E1

-- EXT_paletted_texture

-- These must match the GL_COLOR_TABLE_*_SGI enumerants
COLOR_TABLE_FORMAT_EXT         = 0x80D8
COLOR_TABLE_WIDTH_EXT          = 0x80D9
COLOR_TABLE_RED_SIZE_EXT       = 0x80DA
COLOR_TABLE_GREEN_SIZE_EXT     = 0x80DB
COLOR_TABLE_BLUE_SIZE_EXT      = 0x80DC
COLOR_TABLE_ALPHA_SIZE_EXT     = 0x80DD
COLOR_TABLE_LUMINANCE_SIZE_EXT = 0x80DE
COLOR_TABLE_INTENSITY_SIZE_EXT = 0x80DF

COLOR_INDEX1_EXT               = 0x80E2
COLOR_INDEX2_EXT               = 0x80E3
COLOR_INDEX4_EXT               = 0x80E4
COLOR_INDEX8_EXT               = 0x80E5
COLOR_INDEX12_EXT              = 0x80E6
COLOR_INDEX16_EXT              = 0x80E7

-- WIN_draw_range_elements
MAX_ELEMENTS_VERTICES_WIN      = 0x80E8
MAX_ELEMENTS_INDICES_WIN       = 0x80E9

-- WIN_phong_shading
PHONG_WIN                      = 0x80EA 
PHONG_HINT_WIN                 = 0x80EB 

-- WIN_specular_fog
FOG_SPECULAR_TEXTURE_WIN       = 0x80EC

-- For compatibility with OpenGL v1.0
LOGIC_OP = INDEX_LOGIC_OP
TEXTURE_COMPONENTS = TEXTURE_INTERNAL_FORMAT

-- ***********************************************************

Func("Accum", {abi=abi; ret=void; GLenum --[[op]], GLfloat --[[value]]})
Func("AlphaFunc", {abi=abi; ret=void; GLenum --[[func]], GLclampf --[[ref]]})
Func("AreTexturesResident", {abi=abi; ret=GLboolean; GLsizei --[[n]], ptr --[[const GLuint *textures]], ptr --[[GLboolean *residences]]})
Func("ArrayElement", {abi=abi; ret=void; GLint --[[i]]})
Func("Begin", {abi=abi; ret=void; GLenum --[[mode]]})
Func("BindTexture", {abi=abi; ret=void; GLenum --[[target]], GLuint --[[texture]]})
Func("Bitmap", {abi=abi; ret=void; GLsizei --[[width]], GLsizei --[[height]], GLfloat --[[xorig]], GLfloat --[[yorig]], GLfloat --[[xmove]], GLfloat --[[ymove]], ptr --[[const GLubyte *bitmap]]})
Func("BlendFunc", {abi=abi; ret=void; GLenum --[[sfactor]], GLenum --[[dfactor]]})
Func("CallList", {abi=abi; ret=void; GLuint --[[list]]})
Func("CallLists", {abi=abi; ret=void; GLsizei --[[n]], GLenum --[[type]], ptr --[[const GLvoid *lists]]})
Func("Clear", {abi=abi; ret=void; GLbitfield --[[mask]]})
Func("ClearAccum", {abi=abi; ret=void; GLfloat --[[red]], GLfloat --[[green]], GLfloat --[[blue]], GLfloat --[[alpha]]})
Func("ClearColor", {abi=abi; ret=void; GLclampf --[[red]], GLclampf --[[green]], GLclampf --[[blue]], GLclampf --[[alpha]]})
Func("ClearDepth", {abi=abi; ret=void; GLclampd --[[depth]]})
Func("ClearIndex", {abi=abi; ret=void; GLfloat --[[c]]})
Func("ClearStencil", {abi=abi; ret=void; GLint --[[s]]})
Func("ClipPlane", {abi=abi; ret=void; GLenum --[[plane]], ptr --[[const GLdouble *equation]]})
Func("Color3b", {abi=abi; ret=void; GLbyte --[[red]], GLbyte --[[green]], GLbyte --[[blue]]})
Func("Color3bv", {abi=abi; ret=void; ptr --[[const GLbyte *v]]})
Func("Color3d", {abi=abi; ret=void; GLdouble --[[red]], GLdouble --[[green]], GLdouble --[[blue]]})
Func("Color3dv", {abi=abi; ret=void; ptr --[[const GLdouble *v]]})
Func("Color3f", {abi=abi; ret=void; GLfloat --[[red]], GLfloat --[[green]], GLfloat --[[blue]]})
Func("Color3fv", {abi=abi; ret=void; ptr --[[const GLfloat *v]]})
Func("Color3i", {abi=abi; ret=void; GLint --[[red]], GLint --[[green]], GLint --[[blue]]})
Func("Color3iv", {abi=abi; ret=void; ptr --[[const GLint *v]]})
Func("Color3s", {abi=abi; ret=void; GLshort --[[red]], GLshort --[[green]], GLshort --[[blue]]})
Func("Color3sv", {abi=abi; ret=void; ptr --[[const GLshort *v]]})
Func("Color3ub", {abi=abi; ret=void; GLubyte --[[red]], GLubyte --[[green]], GLubyte --[[blue]]})
Func("Color3ubv", {abi=abi; ret=void; ptr --[[const GLubyte *v]]})
Func("Color3ui", {abi=abi; ret=void; GLuint --[[red]], GLuint --[[green]], GLuint --[[blue]]})
Func("Color3uiv", {abi=abi; ret=void; ptr --[[const GLuint *v]]})
Func("Color3us", {abi=abi; ret=void; GLushort --[[red]], GLushort --[[green]], GLushort --[[blue]]})
Func("Color3usv", {abi=abi; ret=void; ptr --[[const GLushort *v]]})
Func("Color4b", {abi=abi; ret=void; GLbyte --[[red]], GLbyte --[[green]], GLbyte --[[blue]], GLbyte --[[alpha]]})
Func("Color4bv", {abi=abi; ret=void; ptr --[[const GLbyte *v]]})
Func("Color4d", {abi=abi; ret=void; GLdouble --[[red]], GLdouble --[[green]], GLdouble --[[blue]], GLdouble --[[alpha]]})
Func("Color4dv", {abi=abi; ret=void; ptr --[[const GLdouble *v]]})
Func("Color4f", {abi=abi; ret=void; GLfloat --[[red]], GLfloat --[[green]], GLfloat --[[blue]], GLfloat --[[alpha]]})
Func("Color4fv", {abi=abi; ret=void; ptr --[[const GLfloat *v]]})
Func("Color4i", {abi=abi; ret=void; GLint --[[red]], GLint --[[green]], GLint --[[blue]], GLint --[[alpha]]})
Func("Color4iv", {abi=abi; ret=void; ptr --[[const GLint *v]]})
Func("Color4s", {abi=abi; ret=void; GLshort --[[red]], GLshort --[[green]], GLshort --[[blue]], GLshort --[[alpha]]})
Func("Color4sv", {abi=abi; ret=void; ptr --[[const GLshort *v]]})
Func("Color4ub", {abi=abi; ret=void; GLubyte --[[red]], GLubyte --[[green]], GLubyte --[[blue]], GLubyte --[[alpha]]})
Func("Color4ubv", {abi=abi; ret=void; ptr --[[const GLubyte *v]]})
Func("Color4ui", {abi=abi; ret=void; GLuint --[[red]], GLuint --[[green]], GLuint --[[blue]], GLuint --[[alpha]]})
Func("Color4uiv", {abi=abi; ret=void; ptr --[[const GLuint *v]]})
Func("Color4us", {abi=abi; ret=void; GLushort --[[red]], GLushort --[[green]], GLushort --[[blue]], GLushort --[[alpha]]})
Func("Color4usv", {abi=abi; ret=void; ptr --[[const GLushort *v]]})
Func("ColorMask", {abi=abi; ret=void; GLboolean --[[red]], GLboolean --[[green]], GLboolean --[[blue]], GLboolean --[[alpha]]})
Func("ColorMaterial", {abi=abi; ret=void; GLenum --[[face]], GLenum --[[mode]]})
Func("ColorPointer", {abi=abi; ret=void; GLint --[[size]], GLenum --[[type]], GLsizei --[[stride]], ptr --[[const GLvoid *pointer]]})
Func("CopyPixels", {abi=abi; ret=void; GLint --[[x]], GLint --[[y]], GLsizei --[[width]], GLsizei --[[height]], GLenum --[[type]]})
Func("CopyTexImage1D", {abi=abi; ret=void; GLenum --[[target]], GLint --[[level]], GLenum --[[internalFormat]], GLint --[[x]], GLint --[[y]], GLsizei --[[width]], GLint --[[border]]})
Func("CopyTexImage2D", {abi=abi; ret=void; GLenum --[[target]], GLint --[[level]], GLenum --[[internalFormat]], GLint --[[x]], GLint --[[y]], GLsizei --[[width]], GLsizei --[[height]], GLint --[[border]]})
Func("CopyTexSubImage1D", {abi=abi; ret=void; GLenum --[[target]], GLint --[[level]], GLint --[[xoffset]], GLint --[[x]], GLint --[[y]], GLsizei --[[width]]})
Func("CopyTexSubImage2D", {abi=abi; ret=void; GLenum --[[target]], GLint --[[level]], GLint --[[xoffset]], GLint --[[yoffset]], GLint --[[x]], GLint --[[y]], GLsizei --[[width]], GLsizei --[[height]]})
Func("CullFace", {abi=abi; ret=void; GLenum --[[mode]]})
Func("DeleteLists", {abi=abi; ret=void; GLuint --[[list]], GLsizei --[[range]]})
Func("DeleteTextures", {abi=abi; ret=void; GLsizei --[[n]], ptr --[[const GLuint *textures]]})
Func("DepthFunc", {abi=abi; ret=void; GLenum --[[func]]})
Func("DepthMask", {abi=abi; ret=void; GLboolean --[[flag]]})
Func("DepthRange", {abi=abi; ret=void; GLclampd --[[zNear]], GLclampd --[[zFar]]})
Func("Disable", {abi=abi; ret=void; GLenum --[[cap]]})
Func("DisableClientState", {abi=abi; ret=void; GLenum --[[array]]})
Func("DrawArrays", {abi=abi; ret=void; GLenum --[[mode]], GLint --[[first]], GLsizei --[[count]]})
Func("DrawBuffer", {abi=abi; ret=void; GLenum --[[mode]]})
Func("DrawElements", {abi=abi; ret=void; GLenum --[[mode]], GLsizei --[[count]], GLenum --[[type]], ptr --[[const GLvoid *indices]]})
Func("DrawPixels", {abi=abi; ret=void; GLsizei --[[width]], GLsizei --[[height]], GLenum --[[format]], GLenum --[[type]], ptr --[[const GLvoid *pixels]]})
Func("EdgeFlag", {abi=abi; ret=void; GLboolean --[[flag]]})
Func("EdgeFlagPointer", {abi=abi; ret=void; GLsizei --[[stride]], ptr --[[const GLvoid *pointer]]})
Func("EdgeFlagv", {abi=abi; ret=void; ptr --[[const GLboolean *flag]]})
Func("Enable", {abi=abi; ret=void; GLenum --[[cap]]})
Func("EnableClientState", {abi=abi; ret=void; GLenum --[[array]]})
Func("End", {abi=abi; ret=void})
Func("EndList", {abi=abi; ret=void})
Func("EvalCoord1d", {abi=abi; ret=void; GLdouble --[[u]]})
Func("EvalCoord1dv", {abi=abi; ret=void; ptr --[[const GLdouble *u]]})
Func("EvalCoord1f", {abi=abi; ret=void; GLfloat --[[u]]})
Func("EvalCoord1fv", {abi=abi; ret=void; ptr --[[const GLfloat *u]]})
Func("EvalCoord2d", {abi=abi; ret=void; GLdouble --[[u]], GLdouble --[[v]]})
Func("EvalCoord2dv", {abi=abi; ret=void; ptr --[[const GLdouble *u]]})
Func("EvalCoord2f", {abi=abi; ret=void; GLfloat --[[u]], GLfloat --[[v]]})
Func("EvalCoord2fv", {abi=abi; ret=void; ptr --[[const GLfloat *u]]})
Func("EvalMesh1", {abi=abi; ret=void; GLenum --[[mode]], GLint --[[i1]], GLint --[[i2]]})
Func("EvalMesh2", {abi=abi; ret=void; GLenum --[[mode]], GLint --[[i1]], GLint --[[i2]], GLint --[[j1]], GLint --[[j2]]})
Func("EvalPoint1", {abi=abi; ret=void; GLint --[[i]]})
Func("EvalPoint2", {abi=abi; ret=void; GLint --[[i]], GLint --[[j]]})
Func("FeedbackBuffer", {abi=abi; ret=void; GLsizei --[[size]], GLenum --[[type]], ptr --[[GLfloat *buffer]]})
Func("Finish", {abi=abi; ret=void})
Func("Flush", {abi=abi; ret=void})
Func("Fogf", {abi=abi; ret=void; GLenum --[[pname]], GLfloat --[[param]]})
Func("Fogfv", {abi=abi; ret=void; GLenum --[[pname]], ptr --[[const GLfloat *params]]})
Func("Fogi", {abi=abi; ret=void; GLenum --[[pname]], GLint --[[param]]})
Func("Fogiv", {abi=abi; ret=void; GLenum --[[pname]], ptr --[[const GLint *params]]})
Func("FrontFace", {abi=abi; ret=void; GLenum --[[mode]]})
Func("Frustum", {abi=abi; ret=void; GLdouble --[[left]], GLdouble --[[right]], GLdouble --[[bottom]], GLdouble --[[top]], GLdouble --[[zNear]], GLdouble --[[zFar]]})
Func("GenLists", {abi=abi; ret=GLuint; GLsizei --[[range]]})
Func("GenTextures", {abi=abi; ret=void; GLsizei --[[n]], ptr --[[GLuint *textures]]})
Func("GetBooleanv", {abi=abi; ret=void; GLenum --[[pname]], ptr --[[GLboolean *params]]})
Func("GetClipPlane", {abi=abi; ret=void; GLenum --[[plane]], ptr --[[GLdouble *equation]]})
Func("GetDoublev", {abi=abi; ret=void; GLenum --[[pname]], ptr --[[GLdouble *params]]})
Func("GetError", {abi=abi; ret=GLenum})
Func("GetFloatv", {abi=abi; ret=void; GLenum --[[pname]], ptr --[[GLfloat *params]]})
Func("GetIntegerv", {abi=abi; ret=void; GLenum --[[pname]], ptr --[[GLint *params]]})
Func("GetLightfv", {abi=abi; ret=void; GLenum --[[light]], GLenum --[[pname]], ptr --[[GLfloat *params]]})
Func("GetLightiv", {abi=abi; ret=void; GLenum --[[light]], GLenum --[[pname]], ptr --[[GLint *params]]})
Func("GetMapdv", {abi=abi; ret=void; GLenum --[[target]], GLenum --[[query]], ptr --[[GLdouble *v]]})
Func("GetMapfv", {abi=abi; ret=void; GLenum --[[target]], GLenum --[[query]], ptr --[[GLfloat *v]]})
Func("GetMapiv", {abi=abi; ret=void; GLenum --[[target]], GLenum --[[query]], ptr --[[GLint *v]]})
Func("GetMaterialfv", {abi=abi; ret=void; GLenum --[[face]], GLenum --[[pname]], ptr --[[GLfloat *params]]})
Func("GetMaterialiv", {abi=abi; ret=void; GLenum --[[face]], GLenum --[[pname]], ptr --[[GLint *params]]})
Func("GetPixelMapfv", {abi=abi; ret=void; GLenum --[[map]], ptr --[[GLfloat *values]]})
Func("GetPixelMapuiv", {abi=abi; ret=void; GLenum --[[map]], ptr --[[GLuint *values]]})
Func("GetPixelMapusv", {abi=abi; ret=void; GLenum --[[map]], ptr --[[GLushort *values]]})
Func("GetPointerv", {abi=abi; ret=void; GLenum --[[pname]], ptr --[[GLvoid* *params]]})
Func("GetPolygonStipple", {abi=abi; ret=void; ptr --[[GLubyte *mask]]})
Func("GetString", {abi=abi; ret="string"; GLenum --[[name]]})
Func("GetTexEnvfv", {abi=abi; ret=void; GLenum --[[target]], GLenum --[[pname]], ptr --[[GLfloat *params]]})
Func("GetTexEnviv", {abi=abi; ret=void; GLenum --[[target]], GLenum --[[pname]], ptr --[[GLint *params]]})
Func("GetTexGendv", {abi=abi; ret=void; GLenum --[[coord]], GLenum --[[pname]], ptr --[[GLdouble *params]]})
Func("GetTexGenfv", {abi=abi; ret=void; GLenum --[[coord]], GLenum --[[pname]], ptr --[[GLfloat *params]]})
Func("GetTexGeniv", {abi=abi; ret=void; GLenum --[[coord]], GLenum --[[pname]], ptr --[[GLint *params]]})
Func("GetTexImage", {abi=abi; ret=void; GLenum --[[target]], GLint --[[level]], GLenum --[[format]], GLenum --[[type]], ptr --[[GLvoid *pixels]]})
Func("GetTexLevelParameterfv", {abi=abi; ret=void; GLenum --[[target]], GLint --[[level]], GLenum --[[pname]], ptr --[[GLfloat *params]]})
Func("GetTexLevelParameteriv", {abi=abi; ret=void; GLenum --[[target]], GLint --[[level]], GLenum --[[pname]], ptr --[[GLint *params]]})
Func("GetTexParameterfv", {abi=abi; ret=void; GLenum --[[target]], GLenum --[[pname]], ptr --[[GLfloat *params]]})
Func("GetTexParameteriv", {abi=abi; ret=void; GLenum --[[target]], GLenum --[[pname]], ptr --[[GLint *params]]})
Func("Hint", {abi=abi; ret=void; GLenum --[[target]], GLenum --[[mode]]})
Func("IndexMask", {abi=abi; ret=void; GLuint --[[mask]]})
Func("IndexPointer", {abi=abi; ret=void; GLenum --[[type]], GLsizei --[[stride]], ptr --[[const GLvoid *pointer]]})
Func("Indexd", {abi=abi; ret=void; GLdouble --[[c]]})
Func("Indexdv", {abi=abi; ret=void; ptr --[[const GLdouble *c]]})
Func("Indexf", {abi=abi; ret=void; GLfloat --[[c]]})
Func("Indexfv", {abi=abi; ret=void; ptr --[[const GLfloat *c]]})
Func("Indexi", {abi=abi; ret=void; GLint --[[c]]})
Func("Indexiv", {abi=abi; ret=void; ptr --[[const GLint *c]]})
Func("Indexs", {abi=abi; ret=void; GLshort --[[c]]})
Func("Indexsv", {abi=abi; ret=void; ptr --[[const GLshort *c]]})
Func("Indexub", {abi=abi; ret=void; GLubyte --[[c]]})
Func("Indexubv", {abi=abi; ret=void; ptr --[[const GLubyte *c]]})
Func("InitNames", {abi=abi; ret=void})
Func("InterleavedArrays", {abi=abi; ret=void; GLenum --[[format]], GLsizei --[[stride]], ptr --[[const GLvoid *pointer]]})
Func("IsEnabled", {abi=abi; ret=GLboolean; GLenum --[[cap]]})
Func("IsList", {abi=abi; ret=GLboolean; GLuint --[[list]]})
Func("IsTexture", {abi=abi; ret=GLboolean; GLuint --[[texture]]})
Func("LightModelf", {abi=abi; ret=void; GLenum --[[pname]], GLfloat --[[param]]})
Func("LightModelfv", {abi=abi; ret=void; GLenum --[[pname]], ptr --[[const GLfloat *params]]})
Func("LightModeli", {abi=abi; ret=void; GLenum --[[pname]], GLint --[[param]]})
Func("LightModeliv", {abi=abi; ret=void; GLenum --[[pname]], ptr --[[const GLint *params]]})
Func("Lightf", {abi=abi; ret=void; GLenum --[[light]], GLenum --[[pname]], GLfloat --[[param]]})
Func("Lightfv", {abi=abi; ret=void; GLenum --[[light]], GLenum --[[pname]], ptr --[[const GLfloat *params]]})
Func("Lighti", {abi=abi; ret=void; GLenum --[[light]], GLenum --[[pname]], GLint --[[param]]})
Func("Lightiv", {abi=abi; ret=void; GLenum --[[light]], GLenum --[[pname]], ptr --[[const GLint *params]]})
Func("LineStipple", {abi=abi; ret=void; GLint --[[factor]], GLushort --[[pattern]]})
Func("LineWidth", {abi=abi; ret=void; GLfloat --[[width]]})
Func("ListBase", {abi=abi; ret=void; GLuint --[[base]]})
Func("LoadIdentity", {abi=abi; ret=void})
Func("LoadMatrixd", {abi=abi; ret=void; ptr --[[const GLdouble *m]]})
Func("LoadMatrixf", {abi=abi; ret=void; ptr --[[const GLfloat *m]]})
Func("LoadName", {abi=abi; ret=void; GLuint --[[name]]})
Func("LogicOp", {abi=abi; ret=void; GLenum --[[opcode]]})
Func("Map1d", {abi=abi; ret=void; GLenum --[[target]], GLdouble --[[u1]], GLdouble --[[u2]], GLint --[[stride]], GLint --[[order]], ptr --[[const GLdouble *points]]})
Func("Map1f", {abi=abi; ret=void; GLenum --[[target]], GLfloat --[[u1]], GLfloat --[[u2]], GLint --[[stride]], GLint --[[order]], ptr --[[const GLfloat *points]]})
Func("Map2d", {abi=abi; ret=void; GLenum --[[target]], GLdouble --[[u1]], GLdouble --[[u2]], GLint --[[ustride]], GLint --[[uorder]], GLdouble --[[v1]], GLdouble --[[v2]], GLint --[[vstride]], GLint --[[vorder]], ptr --[[const GLdouble *points]]})
Func("Map2f", {abi=abi; ret=void; GLenum --[[target]], GLfloat --[[u1]], GLfloat --[[u2]], GLint --[[ustride]], GLint --[[uorder]], GLfloat --[[v1]], GLfloat --[[v2]], GLint --[[vstride]], GLint --[[vorder]], ptr --[[const GLfloat *points]]})
Func("MapGrid1d", {abi=abi; ret=void; GLint --[[un]], GLdouble --[[u1]], GLdouble --[[u2]]})
Func("MapGrid1f", {abi=abi; ret=void; GLint --[[un]], GLfloat --[[u1]], GLfloat --[[u2]]})
Func("MapGrid2d", {abi=abi; ret=void; GLint --[[un]], GLdouble --[[u1]], GLdouble --[[u2]], GLint --[[vn]], GLdouble --[[v1]], GLdouble --[[v2]]})
Func("MapGrid2f", {abi=abi; ret=void; GLint --[[un]], GLfloat --[[u1]], GLfloat --[[u2]], GLint --[[vn]], GLfloat --[[v1]], GLfloat --[[v2]]})
Func("Materialf", {abi=abi; ret=void; GLenum --[[face]], GLenum --[[pname]], GLfloat --[[param]]})
Func("Materialfv", {abi=abi; ret=void; GLenum --[[face]], GLenum --[[pname]], ptr --[[const GLfloat *params]]})
Func("Materiali", {abi=abi; ret=void; GLenum --[[face]], GLenum --[[pname]], GLint --[[param]]})
Func("Materialiv", {abi=abi; ret=void; GLenum --[[face]], GLenum --[[pname]], ptr --[[const GLint *params]]})
Func("MatrixMode", {abi=abi; ret=void; GLenum --[[mode]]})
Func("MultMatrixd", {abi=abi; ret=void; ptr --[[const GLdouble *m]]})
Func("MultMatrixf", {abi=abi; ret=void; ptr --[[const GLfloat *m]]})
Func("NewList", {abi=abi; ret=void; GLuint --[[list]], GLenum --[[mode]]})
Func("Normal3b", {abi=abi; ret=void; GLbyte --[[nx]], GLbyte --[[ny]], GLbyte --[[nz]]})
Func("Normal3bv", {abi=abi; ret=void; ptr --[[const GLbyte *v]]})
Func("Normal3d", {abi=abi; ret=void; GLdouble --[[nx]], GLdouble --[[ny]], GLdouble --[[nz]]})
Func("Normal3dv", {abi=abi; ret=void; ptr --[[const GLdouble *v]]})
Func("Normal3f", {abi=abi; ret=void; GLfloat --[[nx]], GLfloat --[[ny]], GLfloat --[[nz]]})
Func("Normal3fv", {abi=abi; ret=void; ptr --[[const GLfloat *v]]})
Func("Normal3i", {abi=abi; ret=void; GLint --[[nx]], GLint --[[ny]], GLint --[[nz]]})
Func("Normal3iv", {abi=abi; ret=void; ptr --[[const GLint *v]]})
Func("Normal3s", {abi=abi; ret=void; GLshort --[[nx]], GLshort --[[ny]], GLshort --[[nz]]})
Func("Normal3sv", {abi=abi; ret=void; ptr --[[const GLshort *v]]})
Func("NormalPointer", {abi=abi; ret=void; GLenum --[[type]], GLsizei --[[stride]], ptr --[[const GLvoid *pointer]]})
Func("Ortho", {abi=abi; ret=void; GLdouble --[[left]], GLdouble --[[right]], GLdouble --[[bottom]], GLdouble --[[top]], GLdouble --[[zNear]], GLdouble --[[zFar]]})
Func("PassThrough", {abi=abi; ret=void; GLfloat --[[token]]})
Func("PixelMapfv", {abi=abi; ret=void; GLenum --[[map]], GLsizei --[[mapsize]], ptr --[[const GLfloat *values]]})
Func("PixelMapuiv", {abi=abi; ret=void; GLenum --[[map]], GLsizei --[[mapsize]], ptr --[[const GLuint *values]]})
Func("PixelMapusv", {abi=abi; ret=void; GLenum --[[map]], GLsizei --[[mapsize]], ptr --[[const GLushort *values]]})
Func("PixelStoref", {abi=abi; ret=void; GLenum --[[pname]], GLfloat --[[param]]})
Func("PixelStorei", {abi=abi; ret=void; GLenum --[[pname]], GLint --[[param]]})
Func("PixelTransferf", {abi=abi; ret=void; GLenum --[[pname]], GLfloat --[[param]]})
Func("PixelTransferi", {abi=abi; ret=void; GLenum --[[pname]], GLint --[[param]]})
Func("PixelZoom", {abi=abi; ret=void; GLfloat --[[xfactor]], GLfloat --[[yfactor]]})
Func("PointSize", {abi=abi; ret=void; GLfloat --[[size]]})
Func("PolygonMode", {abi=abi; ret=void; GLenum --[[face]], GLenum --[[mode]]})
Func("PolygonOffset", {abi=abi; ret=void; GLfloat --[[factor]], GLfloat --[[units]]})
Func("PolygonStipple", {abi=abi; ret=void; ptr --[[const GLubyte *mask]]})
Func("PopAttrib", {abi=abi; ret=void})
Func("PopClientAttrib", {abi=abi; ret=void})
Func("PopMatrix", {abi=abi; ret=void})
Func("PopName", {abi=abi; ret=void})
Func("PrioritizeTextures", {abi=abi; ret=void; GLsizei --[[n]], ptr --[[const GLuint *textures]], ptr --[[const GLclampf *priorities]]})
Func("PushAttrib", {abi=abi; ret=void; GLbitfield --[[mask]]})
Func("PushClientAttrib", {abi=abi; ret=void; GLbitfield --[[mask]]})
Func("PushMatrix", {abi=abi; ret=void})
Func("PushName", {abi=abi; ret=void; GLuint --[[name]]})
Func("RasterPos2d", {abi=abi; ret=void; GLdouble --[[x]], GLdouble --[[y]]})
Func("RasterPos2dv", {abi=abi; ret=void; ptr --[[const GLdouble *v]]})
Func("RasterPos2f", {abi=abi; ret=void; GLfloat --[[x]], GLfloat --[[y]]})
Func("RasterPos2fv", {abi=abi; ret=void; ptr --[[const GLfloat *v]]})
Func("RasterPos2i", {abi=abi; ret=void; GLint --[[x]], GLint --[[y]]})
Func("RasterPos2iv", {abi=abi; ret=void; ptr --[[const GLint *v]]})
Func("RasterPos2s", {abi=abi; ret=void; GLshort --[[x]], GLshort --[[y]]})
Func("RasterPos2sv", {abi=abi; ret=void; ptr --[[const GLshort *v]]})
Func("RasterPos3d", {abi=abi; ret=void; GLdouble --[[x]], GLdouble --[[y]], GLdouble --[[z]]})
Func("RasterPos3dv", {abi=abi; ret=void; ptr --[[const GLdouble *v]]})
Func("RasterPos3f", {abi=abi; ret=void; GLfloat --[[x]], GLfloat --[[y]], GLfloat --[[z]]})
Func("RasterPos3fv", {abi=abi; ret=void; ptr --[[const GLfloat *v]]})
Func("RasterPos3i", {abi=abi; ret=void; GLint --[[x]], GLint --[[y]], GLint --[[z]]})
Func("RasterPos3iv", {abi=abi; ret=void; ptr --[[const GLint *v]]})
Func("RasterPos3s", {abi=abi; ret=void; GLshort --[[x]], GLshort --[[y]], GLshort --[[z]]})
Func("RasterPos3sv", {abi=abi; ret=void; ptr --[[const GLshort *v]]})
Func("RasterPos4d", {abi=abi; ret=void; GLdouble --[[x]], GLdouble --[[y]], GLdouble --[[z]], GLdouble --[[w]]})
Func("RasterPos4dv", {abi=abi; ret=void; ptr --[[const GLdouble *v]]})
Func("RasterPos4f", {abi=abi; ret=void; GLfloat --[[x]], GLfloat --[[y]], GLfloat --[[z]], GLfloat --[[w]]})
Func("RasterPos4fv", {abi=abi; ret=void; ptr --[[const GLfloat *v]]})
Func("RasterPos4i", {abi=abi; ret=void; GLint --[[x]], GLint --[[y]], GLint --[[z]], GLint --[[w]]})
Func("RasterPos4iv", {abi=abi; ret=void; ptr --[[const GLint *v]]})
Func("RasterPos4s", {abi=abi; ret=void; GLshort --[[x]], GLshort --[[y]], GLshort --[[z]], GLshort --[[w]]})
Func("RasterPos4sv", {abi=abi; ret=void; ptr --[[const GLshort *v]]})
Func("ReadBuffer", {abi=abi; ret=void; GLenum --[[mode]]})
Func("ReadPixels", {abi=abi; ret=void; GLint --[[x]], GLint --[[y]], GLsizei --[[width]], GLsizei --[[height]], GLenum --[[format]], GLenum --[[type]], ptr --[[GLvoid *pixels]]})
Func("Rectd", {abi=abi; ret=void; GLdouble --[[x1]], GLdouble --[[y1]], GLdouble --[[x2]], GLdouble --[[y2]]})
Func("Rectdv", {abi=abi; ret=void; ptr --[[const GLdouble *v1]], ptr --[[const GLdouble *v2]]})
Func("Rectf", {abi=abi; ret=void; GLfloat --[[x1]], GLfloat --[[y1]], GLfloat --[[x2]], GLfloat --[[y2]]})
Func("Rectfv", {abi=abi; ret=void; ptr --[[const GLfloat *v1]], ptr --[[const GLfloat *v2]]})
Func("Recti", {abi=abi; ret=void; GLint --[[x1]], GLint --[[y1]], GLint --[[x2]], GLint --[[y2]]})
Func("Rectiv", {abi=abi; ret=void; ptr --[[const GLint *v1]], ptr --[[const GLint *v2]]})
Func("Rects", {abi=abi; ret=void; GLshort --[[x1]], GLshort --[[y1]], GLshort --[[x2]], GLshort --[[y2]]})
Func("Rectsv", {abi=abi; ret=void; ptr --[[const GLshort *v1]], ptr --[[const GLshort *v2]]})
Func("RenderMode", {abi=abi; ret=GLint; GLenum --[[mode]]})
Func("Rotated", {abi=abi; ret=void; GLdouble --[[angle]], GLdouble --[[x]], GLdouble --[[y]], GLdouble --[[z]]})
Func("Rotatef", {abi=abi; ret=void; GLfloat --[[angle]], GLfloat --[[x]], GLfloat --[[y]], GLfloat --[[z]]})
Func("Scaled", {abi=abi; ret=void; GLdouble --[[x]], GLdouble --[[y]], GLdouble --[[z]]})
Func("Scalef", {abi=abi; ret=void; GLfloat --[[x]], GLfloat --[[y]], GLfloat --[[z]]})
Func("Scissor", {abi=abi; ret=void; GLint --[[x]], GLint --[[y]], GLsizei --[[width]], GLsizei --[[height]]})
Func("SelectBuffer", {abi=abi; ret=void; GLsizei --[[size]], ptr --[[GLuint *buffer]]})
Func("ShadeModel", {abi=abi; ret=void; GLenum --[[mode]]})
Func("StencilFunc", {abi=abi; ret=void; GLenum --[[func]], GLint --[[ref]], GLuint --[[mask]]})
Func("StencilMask", {abi=abi; ret=void; GLuint --[[mask]]})
Func("StencilOp", {abi=abi; ret=void; GLenum --[[fail]], GLenum --[[zfail]], GLenum --[[zpass]]})
Func("TexCoord1d", {abi=abi; ret=void; GLdouble --[[s]]})
Func("TexCoord1dv", {abi=abi; ret=void; ptr --[[const GLdouble *v]]})
Func("TexCoord1f", {abi=abi; ret=void; GLfloat --[[s]]})
Func("TexCoord1fv", {abi=abi; ret=void; ptr --[[const GLfloat *v]]})
Func("TexCoord1i", {abi=abi; ret=void; GLint --[[s]]})
Func("TexCoord1iv", {abi=abi; ret=void; ptr --[[const GLint *v]]})
Func("TexCoord1s", {abi=abi; ret=void; GLshort --[[s]]})
Func("TexCoord1sv", {abi=abi; ret=void; ptr --[[const GLshort *v]]})
Func("TexCoord2d", {abi=abi; ret=void; GLdouble --[[s]], GLdouble --[[t]]})
Func("TexCoord2dv", {abi=abi; ret=void; ptr --[[const GLdouble *v]]})
Func("TexCoord2f", {abi=abi; ret=void; GLfloat --[[s]], GLfloat --[[t]]})
Func("TexCoord2fv", {abi=abi; ret=void; ptr --[[const GLfloat *v]]})
Func("TexCoord2i", {abi=abi; ret=void; GLint --[[s]], GLint --[[t]]})
Func("TexCoord2iv", {abi=abi; ret=void; ptr --[[const GLint *v]]})
Func("TexCoord2s", {abi=abi; ret=void; GLshort --[[s]], GLshort --[[t]]})
Func("TexCoord2sv", {abi=abi; ret=void; ptr --[[const GLshort *v]]})
Func("TexCoord3d", {abi=abi; ret=void; GLdouble --[[s]], GLdouble --[[t]], GLdouble --[[r]]})
Func("TexCoord3dv", {abi=abi; ret=void; ptr --[[const GLdouble *v]]})
Func("TexCoord3f", {abi=abi; ret=void; GLfloat --[[s]], GLfloat --[[t]], GLfloat --[[r]]})
Func("TexCoord3fv", {abi=abi; ret=void; ptr --[[const GLfloat *v]]})
Func("TexCoord3i", {abi=abi; ret=void; GLint --[[s]], GLint --[[t]], GLint --[[r]]})
Func("TexCoord3iv", {abi=abi; ret=void; ptr --[[const GLint *v]]})
Func("TexCoord3s", {abi=abi; ret=void; GLshort --[[s]], GLshort --[[t]], GLshort --[[r]]})
Func("TexCoord3sv", {abi=abi; ret=void; ptr --[[const GLshort *v]]})
Func("TexCoord4d", {abi=abi; ret=void; GLdouble --[[s]], GLdouble --[[t]], GLdouble --[[r]], GLdouble --[[q]]})
Func("TexCoord4dv", {abi=abi; ret=void; ptr --[[const GLdouble *v]]})
Func("TexCoord4f", {abi=abi; ret=void; GLfloat --[[s]], GLfloat --[[t]], GLfloat --[[r]], GLfloat --[[q]]})
Func("TexCoord4fv", {abi=abi; ret=void; ptr --[[const GLfloat *v]]})
Func("TexCoord4i", {abi=abi; ret=void; GLint --[[s]], GLint --[[t]], GLint --[[r]], GLint --[[q]]})
Func("TexCoord4iv", {abi=abi; ret=void; ptr --[[const GLint *v]]})
Func("TexCoord4s", {abi=abi; ret=void; GLshort --[[s]], GLshort --[[t]], GLshort --[[r]], GLshort --[[q]]})
Func("TexCoord4sv", {abi=abi; ret=void; ptr --[[const GLshort *v]]})
Func("TexCoordPointer", {abi=abi; ret=void; GLint --[[size]], GLenum --[[type]], GLsizei --[[stride]], ptr --[[const GLvoid *pointer]]})
Func("TexEnvf", {abi=abi; ret=void; GLenum --[[target]], GLenum --[[pname]], GLfloat --[[param]]})
Func("TexEnvfv", {abi=abi; ret=void; GLenum --[[target]], GLenum --[[pname]], ptr --[[const GLfloat *params]]})
Func("TexEnvi", {abi=abi; ret=void; GLenum --[[target]], GLenum --[[pname]], GLint --[[param]]})
Func("TexEnviv", {abi=abi; ret=void; GLenum --[[target]], GLenum --[[pname]], ptr --[[const GLint *params]]})
Func("TexGend", {abi=abi; ret=void; GLenum --[[coord]], GLenum --[[pname]], GLdouble --[[param]]})
Func("TexGendv", {abi=abi; ret=void; GLenum --[[coord]], GLenum --[[pname]], ptr --[[const GLdouble *params]]})
Func("TexGenf", {abi=abi; ret=void; GLenum --[[coord]], GLenum --[[pname]], GLfloat --[[param]]})
Func("TexGenfv", {abi=abi; ret=void; GLenum --[[coord]], GLenum --[[pname]], ptr --[[const GLfloat *params]]})
Func("TexGeni", {abi=abi; ret=void; GLenum --[[coord]], GLenum --[[pname]], GLint --[[param]]})
Func("TexGeniv", {abi=abi; ret=void; GLenum --[[coord]], GLenum --[[pname]], ptr --[[const GLint *params]]})
Func("TexImage1D", {abi=abi; ret=void; GLenum --[[target]], GLint --[[level]], GLint --[[internalformat]], GLsizei --[[width]], GLint --[[border]], GLenum --[[format]], GLenum --[[type]], ptr --[[const GLvoid *pixels]]})
Func("TexImage2D", {abi=abi; ret=void; GLenum --[[target]], GLint --[[level]], GLint --[[internalformat]], GLsizei --[[width]], GLsizei --[[height]], GLint --[[border]], GLenum --[[format]], GLenum --[[type]], ptr --[[const GLvoid *pixels]]})
Func("TexParameterf", {abi=abi; ret=void; GLenum --[[target]], GLenum --[[pname]], GLfloat --[[param]]})
Func("TexParameterfv", {abi=abi; ret=void; GLenum --[[target]], GLenum --[[pname]], ptr --[[const GLfloat *params]]})
Func("TexParameteri", {abi=abi; ret=void; GLenum --[[target]], GLenum --[[pname]], GLint --[[param]]})
Func("TexParameteriv", {abi=abi; ret=void; GLenum --[[target]], GLenum --[[pname]], ptr --[[const GLint *params]]})
Func("TexSubImage1D", {abi=abi; ret=void; GLenum --[[target]], GLint --[[level]], GLint --[[xoffset]], GLsizei --[[width]], GLenum --[[format]], GLenum --[[type]], ptr --[[const GLvoid *pixels]]})
Func("TexSubImage2D", {abi=abi; ret=void; GLenum --[[target]], GLint --[[level]], GLint --[[xoffset]], GLint --[[yoffset]], GLsizei --[[width]], GLsizei --[[height]], GLenum --[[format]], GLenum --[[type]], ptr --[[const GLvoid *pixels]]})
Func("Translated", {abi=abi; ret=void; GLdouble --[[x]], GLdouble --[[y]], GLdouble --[[z]]})
Func("Translatef", {abi=abi; ret=void; GLfloat --[[x]], GLfloat --[[y]], GLfloat --[[z]]})
Func("Vertex2d", {abi=abi; ret=void; GLdouble --[[x]], GLdouble --[[y]]})
Func("Vertex2dv", {abi=abi; ret=void; ptr --[[const GLdouble *v]]})
Func("Vertex2f", {abi=abi; ret=void; GLfloat --[[x]], GLfloat --[[y]]})
Func("Vertex2fv", {abi=abi; ret=void; ptr --[[const GLfloat *v]]})
Func("Vertex2i", {abi=abi; ret=void; GLint --[[x]], GLint --[[y]]})
Func("Vertex2iv", {abi=abi; ret=void; ptr --[[const GLint *v]]})
Func("Vertex2s", {abi=abi; ret=void; GLshort --[[x]], GLshort --[[y]]})
Func("Vertex2sv", {abi=abi; ret=void; ptr --[[const GLshort *v]]})
Func("Vertex3d", {abi=abi; ret=void; GLdouble --[[x]], GLdouble --[[y]], GLdouble --[[z]]})
Func("Vertex3dv", {abi=abi; ret=void; ptr --[[const GLdouble *v]]})
Func("Vertex3f", {abi=abi; ret=void; GLfloat --[[x]], GLfloat --[[y]], GLfloat --[[z]]})
Func("Vertex3fv", {abi=abi; ret=void; ptr --[[const GLfloat *v]]})
Func("Vertex3i", {abi=abi; ret=void; GLint --[[x]], GLint --[[y]], GLint --[[z]]})
Func("Vertex3iv", {abi=abi; ret=void; ptr --[[const GLint *v]]})
Func("Vertex3s", {abi=abi; ret=void; GLshort --[[x]], GLshort --[[y]], GLshort --[[z]]})
Func("Vertex3sv", {abi=abi; ret=void; ptr --[[const GLshort *v]]})
Func("Vertex4d", {abi=abi; ret=void; GLdouble --[[x]], GLdouble --[[y]], GLdouble --[[z]], GLdouble --[[w]]})
Func("Vertex4dv", {abi=abi; ret=void; ptr --[[const GLdouble *v]]})
Func("Vertex4f", {abi=abi; ret=void; GLfloat --[[x]], GLfloat --[[y]], GLfloat --[[z]], GLfloat --[[w]]})
Func("Vertex4fv", {abi=abi; ret=void; ptr --[[const GLfloat *v]]})
Func("Vertex4i", {abi=abi; ret=void; GLint --[[x]], GLint --[[y]], GLint --[[z]], GLint --[[w]]})
Func("Vertex4iv", {abi=abi; ret=void; ptr --[[const GLint *v]]})
Func("Vertex4s", {abi=abi; ret=void; GLshort --[[x]], GLshort --[[y]], GLshort --[[z]], GLshort --[[w]]})
Func("Vertex4sv", {abi=abi; ret=void; ptr --[[const GLshort *v]]})
Func("VertexPointer", {abi=abi; ret=void; GLint --[[size]], GLenum --[[type]], GLsizei --[[stride]], ptr --[[const GLvoid *pointer]]})
Func("Viewport", {abi=abi; ret=void; GLint --[[x]], GLint --[[y]], GLsizei --[[width]], GLsizei --[[height]]})

--[[
-- EXT_vertex_array
typedef void (APIENTRY * PFNGLARRAYELEMENTEXTPROC) (GLint i);
typedef void (APIENTRY * PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count);
typedef void (APIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
typedef void (APIENTRY * PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
typedef void (APIENTRY * PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
typedef void (APIENTRY * PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
typedef void (APIENTRY * PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
typedef void (APIENTRY * PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer);
typedef void (APIENTRY * PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params);
typedef void (APIENTRY * PFNGLARRAYELEMENTARRAYEXTPROC)(GLenum mode, GLsizei count, const GLvoid* pi);

-- WIN_draw_range_elements
typedef void (APIENTRY * PFNGLDRAWRANGEELEMENTSWINPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);

-- WIN_swap_hint
typedef void (APIENTRY * PFNGLADDSWAPHINTRECTWINPROC)  (GLint x, GLint y, GLsizei width, GLsizei height);

-- EXT_paletted_texture
typedef void (APIENTRY * PFNGLCOLORTABLEEXTPROC)
    (GLenum target, GLenum internalFormat, GLsizei width, GLenum format,
     GLenum type, const GLvoid *data);
typedef void (APIENTRY * PFNGLCOLORSUBTABLEEXTPROC)
    (GLenum target, GLsizei start, GLsizei count, GLenum format,
     GLenum type, const GLvoid *data);
typedef void (APIENTRY * PFNGLGETCOLORTABLEEXTPROC)
    (GLenum target, GLenum format, GLenum type, GLvoid *data);
typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC)
    (GLenum target, GLenum pname, GLint *params);
typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC)
    (GLenum target, GLenum pname, GLfloat *params);
--]]

if alien.platform == 'windows' then
  wglCreateContext = lib.wglCreateContext
  wglCreateContext:types{ ret="pointer"; "pointer" }
  
  wglMakeCurrent = lib.wglMakeCurrent
  wglMakeCurrent:types{ ret="int"; "pointer", "pointer" }
  
  wglDeleteContext = lib.wglDeleteContext
  wglDeleteContext:types{ ret="int"; "pointer" }
end

local tryGetName
local function tryGetAux(name)
  return lib[name]
end
  
local function tryGet(name)
  tryGetName = name
  local success, result = pcall(tryGetAux)
  if success then
    return result
  else
    return nil
  end
end

do
  local _GetProcAddress = tryGet("wglGetProcAddress") or tryGet("glXGetProcAddress") or tryGet("glXGetProcAddressARB")
  
  if _GetProcAddress then
  
    _GetProcAddress:types{ ret="pointer"; "string" }
  
    function GetProcedure(name, ...)
      if proc then
        return proc
      end
      proc = _GetProcAddress(name)
      if proc then
        proc = alien.funcptr(proc)
        proc:types(...)
        return proc
      end
      return nil
    end
  
  else
  
    function GetProcedure(name, ...)
      local func = tryGet(name)
      if func then
        func:types(...)
        return func
      end
      return nil
    end
  
  end
end
